<template>
	<view>
		<nav-bar type="transparentFixed" :titleCenter="false" :scrollTop="scrollTop"
			transparentFixedFontColor="rgba(0, 0, 0, 0)">
			<view slot="left" style="padding-left: 30px;">
				<text style="font-weight: bold;font-size: 50rpx;margin-right:10rpx;">100</text>
				<text>分钟</text>
			</view>
			<view slot="right">
				<u-icon @tap="gopage('/pages/user/search')" name="search" :size="50"
					style="margin-right: 20px;"></u-icon>
				<u-icon :name="vuex_bookbutton" :size="50" style="margin-right: 20px;" @click="tabook"></u-icon>
			</view>
			<view slot="transparentFixedRight" style="color: #000000;">
				<u-icon @tap="gopage('/pages/user/search')" name="search" :size="50"
					style="margin-right: 20px;"></u-icon>
				<u-icon :name="vuex_bookbutton" :size="50" style="margin-right: 20px;" @click="tabook"></u-icon>
			</view>
		</nav-bar>
		<view class="status_bar" style="background-image: url(../../static/image/bj.png);background-position:center;">
			<view
				style="margin-left:50px;text-align:center;margin-top: calc(var(--status-bar-height) + 30px);position: absolute;">
				<view style="font-weight: bold;font-size: 70rpx;">100</view>
				<text class="u-font-10 u-type-info-info">今日已读/分钟</text>
			</view>
		</view>
		<view class="book-wrap">
			<view class="title">
				最近阅读
			</view>
			<image src="/static/image/196.jpg"  mode="aspectFill"></image>
			<view class="content">
				<view class="booktitle">仙武帝尊</view>
				<view class="bookcontent u-line-2 u-light-color">
					上次阅读至 31 章
				</view>
				<view @tap="gopage('/pages/book/read')" class="bookfoot u-light-color">
					继续阅读 >
				</view>
			</view>
			<view class="foot">
				<u-line length="65px" margin="30rpx" direction="col" :hair-line="false"></u-line>
				<u-icon name="clock" @tap="gopage('/pages/user/history')" :size="60" color="#82848a"
					label-color="#82848a" label-pos="bottom" label="阅读记录"></u-icon>
			</view>
		</view>
		<!-- #ifdef APP-PLUS || H5 -->
		<view style="margin-top:110px;">
		<!-- #endif -->
			<!-- #ifdef MP-WEIXIN || MP-QQ -->
			<view style="margin-top:90px;">
			<!-- #endif -->
				<mescroll-body-diy height="470px" @init="mescrollInit" :down="downOption" :up="upOption"
					@down="downCallback" @up="upCallback">
					<view v-if="vuex_bookstyle == 'card'">
						<card-box :book="booklist" ></card-box>
					</view>

					<view v-if="vuex_bookstyle == 'list'">
						<list-box :book="booklist" :options="options" ></list-box>
					</view>
					<view style="margin-bottom:30rpx;">
						<u-divider>您的书架共有9本书</u-divider>
					</view>
				</mescroll-body-diy>
			</view>
			<u-tabbar v-model="vuex_current" :activeColor="vuex_activeColor" :list="vuex_tabbar"></u-tabbar>
		</view>
</template>

<script>
	export default {
		data() {
			return {
				btnWidth: 180,
				options: [{
					text: '删除',
					style: {
						backgroundColor: '#dd524d'
					}
				}],
				booklist: [{
						image: '/static/image/196.jpg',
						name: '仙武帝尊',
						read: 699,
						newest: 700,
						newestname: '第700章 我是大主宰',
						update: true,
						reading: true
					},
					{
						image: "https://pic.baike.soso.com/ugc/baikepic2/19045/cut-20191023134121-548097394_jpg_190_238_7208.jpg/300",
						name: '元尊',
						read: 0,
						newest: 1384,
						newestname: '第一千三百八十四章 再聚苍玄',
						update: false,
						reading: false
					},
					{
						image: 'https://bookcover.yuewen.com/qdbimg/349573/1209977/180',
						name: '斗破苍穹',
						read: 0,
						newest: 1624,
						newestname: '第一千六百二十四章 结束，也是开始。〔大结局〕',
						update: false,
						reading: false
					},
					{
						image: 'https://bookcover.yuewen.com/qdbimg/349573/2048120/180',
						name: '武动乾坤',
						read: 0,
						newest: 1327,
						newestname: '第1327章 新书大主宰已发。',
						update: false,
						reading: false
					},
					{
						image: 'http://img03.sogoucdn.com/app/a/10070003/4F3048984D05ABC2098AF9FBB7036EDE',
						name: '大主宰',
						read: 0,
						newest: 1551,
						newestname: '第一千五百五十一章 邪神陨落（大结局）',
						update: false,
						reading: false
					},
					{
						image: '/static/image/196.jpg',
						name: '仙武帝尊',
						read: 699,
						newest: 700,
						newestname: '第700章 我是大主宰',
						update: false,
						reading: false
					},
					{
						image: '/static/image/196.jpg',
						name: '仙武帝尊',
						read: 699,
						newest: 700,
						newestname: '第700章 我是大主宰',
						update: false,
						reading: false
					},
					{
						image: '/static/image/196.jpg',
						name: '仙武帝尊',
						read: 699,
						newest: 700,
						newestname: '第700章 我是大主宰',
						update: false,
						reading: false
					},
					{
						image: '/static/image/196.jpg',
						name: '仙武帝尊',
						read: 699,
						newest: 700,
						newestname: '第700章 我是大主宰',
						update: false,
						reading: false
					},
					{
						image: '/static/image/196.jpg',
						name: '仙武帝尊',
						read: 699,
						newest: 700,
						newestname: '第700章 我是大主宰',
						update: false,
						reading: false
					}
				],
				scrollTop: 0,
				downOption: {
					auto: false,
					offset: 50
				},
				upOption: {
					auto: true,
					use: false,
					isBounce: true,
					page: {
						num: 0,
						size: 10,
						time: null
					},
					empty: {
						use: true,
						icon: null,
						tip: "暂无相关数据",
						btnText: "",
						fixed: false,
						top: "100rpx",
						zIndex: 99
					}
				}
			}
		},
		onShow() {

		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		methods: {
			tabinfo() {
				this.$u.route({
					url: 'pages/book/bookinfo'
				})
			},
			touchstart(index) {
				console.log(index)
				return false;
			},
			tabook() {
				if (this.vuex_bookstyle == 'card') {
					this.$u.vuex('vuex_bookstyle', 'list');
					this.$u.vuex('vuex_bookbutton', 'list-dot');
				} else if (this.vuex_bookstyle == 'list') {
					this.$u.vuex('vuex_bookstyle', 'card');
					this.$u.vuex('vuex_bookbutton', 'grid');
				}
				// this.mescroll.scrollTo(0);
				// this.mescroll.triggerDownScroll()
			},
			/*下拉刷新的回调 */
			downCallback() {
				setTimeout(() => {
					this.mescroll.endSuccess();
				}, 2000);

			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				setTimeout(() => {
					this.mescroll.endErr();
				}, 2000);
			},
			gohome() {
				this.$u.route({
					type: 'tab',
					url: 'pages/home/home'
				})
			},
			gopage: function(url) {
				console.log(url);
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>
<style lang="scss">
	.status_bar {
		height: calc(var(--status-bar-height) + 130px);
		width: 100%;
	}

	.book-wrap {
		margin-bottom: 15px;
		border-radius: 2px;
		background-color: #fff;
		box-shadow: 5px 5px 5px 0 rgba(0, 0, 0, .05);
		-webkit-box-shadow: #d4d2d2 0px 0px 10px;
		-moz-box-shadow: #d4d2d2 0px 0px 10px;

		position: absolute;
		display: flex;
		overflow: hidden;
		height: auto;
		margin-top: -15px;
		left: 30rpx;
		right: 30rpx;
		border-radius: 16rpx;
		background-color: #FFFFFF;

		.title {
			text-align: center;
			writing-mode: vertical-lr;
			padding: 46rpx 10rpx;
			font-size: 23rpx;
			color: #2b85e4;
			font-weight: bold;
			background-color: #E3F1FC;
		}

		.content {
			display: flex;
			flex-direction: column;
			padding: 25rpx 25rpx 0 0;

			.booktitle {
				font-size: 28rpx;
				line-height: 40rpx;
			}

			.bookcontent {
				font-size: 25rpx;
			}

			.bookfoot {
				margin-top: 28rpx;
				font-size: 25rpx;
			}
		}

		.foot {
			display: flex;
			position: absolute;
			right: 30rpx;
		}
	}

	.book-wrap image {
		padding: 25rpx;
		width: 100rpx;
		height: 140rpx;
	}
</style>